<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="金额" >
        <el-input v-model="form.outputCount" style="width: 230px"></el-input>
      </el-form-item>

      <el-form-item label="时间">
<!--        <el-col :span="11">-->
<!--          <el-date-picker type="date" placeholder="选择日期" v-model="form.outputDate" style="width: 230px;"></el-date-picker>-->
<!--         </el-col>-->
        <el-date-picker
            v-model="form.outputDate"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            align="right"
            :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="种类">
        <el-select v-model="form.outputKind" placeholder="请选择种类" >
          <el-option label="衣服" value="衣服"></el-option>
          <el-option label="零食" value="零食"></el-option>
          <el-option label="水果" value="水果"></el-option>
          <el-option label="住宿" value="住宿"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="支付方式">
        <el-select v-model="form.outputMethod" placeholder="请选择支付方式" @change="getMethod">
          <el-option label="现金" value="现金"></el-option>
          <el-option label="微信" value="微信"></el-option>
          <el-option label="支付宝" value="支付宝"></el-option>
          <el-option label="花呗" value="花呗"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="备注">
        <el-input type="textarea" v-model="form.outputText" style="width: 230px"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="updatetOutput(form)">确认修改</el-button>
        <router-link to="/output"> <el-button>取消</el-button> </router-link>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
export default {
  name: "UpdateOutput",
  data(){
    return {
      form: {
        outputCount:'',
        outputDate:'',
        outputId:1,
        outputKind:'',
        outputMethod:'',
        outputText:''
      }
    }
  },
  methods:{
    getMethod(){
      console.log(this.form.outputMethod)
    },
    updatetOutput(form){
      const data=form
      console.log(form)
      axios({
        url: "http://localhost:9090/output/updateOutput",
        data: data,
        method:'post',
        //ajax
        // dataType: "JSON",
        // type: "post",
        // contentType: ‘application/json;charset=UTF-8‘, //不能加
        // success: function (msg) {
        //   console.log(msg)
        // }
      })
          .then(function (resp){
            console.log(resp)
          })
          .catch(function (error){
            console.log(error)
          })
      this.$router.push({
        path: '/output',
        name: 'Output'
      })
    }

  },
  created() {

  },
  mounted:function (){
    this.form=this.$route.params.msgKey
    console.log(this.form)
  }
}
</script>

<style scoped>

</style>